package com.wc.AlgoOJ._DFS.CF4037_黑白平衡子树;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/3/6 19:19
 * @description http://43.138.190.70:8888/p/CF4037
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 4010;
    // t[i][0] 表示有几个孩子,不仅仅有一个孩子
    static int[][] t = new int[N][N];
    // 每颗子树的黑白色的数量
    static int[][] wb = new int[N][2];
    static char[] color = new char[N];
    static int T, n;

    public static void main(String[] args) {
        T = sc.nextInt();
        while (T-- > 0) {
            n = sc.nextInt();
            for (int i = 2; i <= n; i++) {
                int fa = sc.nextInt();
                t[fa][++t[fa][0]] = i;
            }
            color = (" " + sc.next()).toCharArray();
            dfs(1);
            int res = 0;
            for (int i = 1; i <= n; i++) {
                if (wb[i][0] == wb[i][1]) {
                    res++;
                }
            }
            out.println(res);
            for (int i = 1; i <= n; i++) Arrays.fill(t[i], 0, t[i][0] + 1, 0);
            for (int i = 1; i <= n; i++) Arrays.fill(wb[i], 0);

        }
        out.flush();
    }

    static void dfs(int root) {
        if (root == 0) {
            return;
        }
        if (color[root] == 'W') wb[root][0]++;
        else wb[root][1]++;
        for (int i = 1; i <= t[root][0]; i++) {
            dfs(t[root][i]);
            wb[root][0] += wb[t[root][i]][0];
            wb[root][1] += wb[t[root][i]][1];
        }
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
